# This Python file uses the following encoding: utf-8
# Django settings for ghap project.

import os.path
import sys

sys.path.insert(0, "/usr/local/lib/python2.6/site-packages" )

BI_DIR = '/tmp/'

DEBUG = True
TEMPLATE_DEBUG = DEBUG

LANGUAGE_CODE = 'ca_ES'

ADMINS = (
     ('GHAP Master', 'dherrera@gmail.com'),
)
EMAIL_HOST='smtp.gmail.com'
EMAIL_HOST_USER='ghap.inst.cendrassos@gmail.com'
EMAIL_HOST_PASSWORD='XXXXXXXXXXXXXXXX'
EMAIL_PORT=587
EMAIL_USE_TLS=True
SERVER_EMAIL='ghap.inst.cendrassos@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

MANAGERS = ADMINS

LOGIN_URL="/usuaris/login"

#https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.contrib.messages.context_processors.messages",
    "django.core.context_processors.csrf",
    'utils.context_processors.dades_basiques',
    )


SESSION_ENGINE = "django.contrib.sessions.backends.db"


#"django.contrib.sessions.backends.cache"
#'django.contrib.sessions.backends.cached_db'

DATABASES = {
    'default': {
        'ENGINE' : 'django.db.backends.mysql',           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        #'NAME' : 'ghap'   ,          # Or path to database file if using sqlite3.
        #'USER' : 'usrGhap',             # Not used with sqlite3.
        'NAME' : 'ghapMallol'   ,          # Or path to database file if using sqlite3.
        'USER' : 'usrMallol',             # Not used with sqlite3.
        'PASSWORD' : 'ies',         # Not used with sqlite3.
        'HOST' : 'localhost',             # Set to empty string for localhost. Not used with sqlite3.
        'PORT' : ''       ,      # Set to empty string for default. Not used with sqlite3.
        'OPTIONS' : {
           "init_command": "SET storage_engine=INNODB",
        }
        
    }
}


# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Andorra'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'assets')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = 'https://www.iescendrassos.net/assets'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)


# Make this unique, and don't share it with anybody.
SECRET_KEY = '==5(+&ra1q3^vpu+!rl=u3f1zhuhw!k@r3cug#wd%e5swgu%lt'

DATE_INPUT_FORMATS=('%d/%m/%Y','%Y-%m-%d')

DATETIME_INPUT_FORMATS= ('%d/%m/%Y %H:%M','%d/%m/%Y %H:%M:%S',
                         '%d-%m-%Y %H:%M','%d-%m-%Y %H:%M:%S',)


# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader')


#TEMPLATE_LOADERS = (
#    ('django.template.loaders.cached.Loader', (
#        'django.template.loaders.filesystem.Loader',
#        'django.template.loaders.app_directories.Loader',
#    )),
#)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.transaction.TransactionMiddleware',    
    'ghap.utils.middleware.NoCacheMiddleware',   
    'ghap.utils.middleware.timeOutMiddleware', 
    'ghap.utils.middleware.IncludeLoginInErrors',
    #'debug_toolbar.middleware.DebugToolbarMiddleware',
    
)

ROOT_URLCONF = 'ghap.urls'

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
    os.path.join(os.path.dirname(__file__), 'missatgeria/templates'),
    os.path.join(os.path.dirname(__file__), 'alumnes/templates'),
    os.path.join(os.path.dirname(__file__), 'assignatures/templates'),
    os.path.join(os.path.dirname(__file__), 'horaris/templates'),
    os.path.join(os.path.dirname(__file__), 'presencia/templates'),
    os.path.join(os.path.dirname(__file__), 'incidencies/templates'),
    os.path.join(os.path.dirname(__file__), 'tutoria/templates'),
    os.path.join(os.path.dirname(__file__), 'utils/templates'),
    os.path.join(os.path.dirname(__file__), 'extKronowin/templates'),
    os.path.join(os.path.dirname(__file__), 'avaluacioQualitativa/templates'),
    os.path.join(os.path.dirname(__file__), 'realacioFamilies/templates'),
    os.path.join(os.path.dirname(__file__), 'sortides/templates'),    
    os.path.join(os.path.dirname(__file__), 'todo/templates'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'missatgeria',
    'alumnes',
    'assignatures',
    'horaris',
    'presencia',
    'incidencies',
    'tutoria',
    'utils',
    'extKronowin',
    'avaluacioQualitativa',
    'todo',
    'usuaris',
    'relacioFamilies',
    'sortides',
    'baixes',
    'BI',
    #'debug_toolbar',
)

#debug--------------------------
DEBUG_TOOLBAR_PANELS = (
#    'debug_toolbar.panels.version.VersionDebugPanel',
#    'debug_toolbar.panels.timer.TimerDebugPanel',
#    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
#    'debug_toolbar.panels.headers.HeaderDebugPanel',
#    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
#    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
#    'debug_toolbar.panels.signals.SignalDebugPanel',
#    'debug_toolbar.panels.logger.LoggingPanel',
)

#INTERNAL_IPS = ('127.0.0.1',)

from lxml import etree
PREDICTION_TREE = etree.parse( os.path.join(os.path.dirname(__file__), 'BI/PMML/previsioPresencia.pmml' )  )

#catpcha ----------------

RECAPTCHA_PUBLIC = '6LdqR88SAAAAADTncufFcWkLm2uSbA5g8M2pcM36'
RECAPTCHA_PRIVATE = '6LdqR88SAAAAAEszmJLwNh5zDjm5mnZKdEi1ZA8a'
RECAPTCHA_USE_SSL =True

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}


